package com.carleasoft.mps.adu.business.user.controller;

import com.carleasoft.mps.adu.business.user.bean.po.AuthorityUserTypePo;
import com.carleasoft.mps.adu.business.user.service.AuthorityUserTypeService;
import com.carleasoft.mps.core.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>Description: UserType</p>
 * @since 2020-05-09
 * @author ztm
 */
@RestController
@RequestMapping("/userType")
public class AuthorityUserTypeController {

    @Autowired
    AuthorityUserTypeService authorityUserTypeService;

    /**
     * 添加用户类型
     * ok
     * @param authorityUserTypePo
     * @return ResultBody
     */
    @PostMapping("/add")
    public R addUserType(@RequestBody AuthorityUserTypePo authorityUserTypePo){
        authorityUserTypeService.addUserType(authorityUserTypePo);
        return R.ok();
    }
    /**
     * 编辑用户类型
     * ok
     * @param authorityUserTypePo
     * @return ResultBody
     */
    @PostMapping("/update")
    public R updateUserType(@RequestBody AuthorityUserTypePo authorityUserTypePo){

        authorityUserTypeService.updateUserType(authorityUserTypePo);
        return R.ok();
    }

    /**
     * 删除用户类型
     * ok
     * @param userTypeCode
     * @return ResultBody
     */
    @PostMapping("/delete")
    public R deleteUserType(@RequestBody String userTypeCode){
        authorityUserTypeService.deleteUserType(userTypeCode);
        return R.ok();
    }

    @PostMapping("/list")
    public R pageQuery(@RequestBody AuthorityUserTypePo authorityUserTypePo){
        return R.ok(authorityUserTypeService.userTypePage(authorityUserTypePo));
    }
}
